<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <!-- 单个元素 -->
    <span v-once>This will never change: {{msg}}</span>
    <!-- 有子元素 -->
    <div v-once>
      <h1>comment</h1>
      <p>{{msg}}</p>
    </div>
    <h1>{{msg}}</h1>
    <!-- 组件 -->
    <my-component v-once :comment="msg"></my-component>
    <!-- `v-for` 指令 -->
    <ul>
      <li v-for="i in list" v-once>{{i}}</li>
    </ul>

    <button @click="clickAction">{{msg}}</button>
  </div>
  <script src="./js/vue.js"></script>
  <script>
    const app = new Vue({
      el: "#app",
      data: {
        username: "",
        age: 0,
        msg: "这是第一次消息",
      },
      methods: {
        clickAction() {
          this.age += 1;
          this.msg = "这是第" + this.age + "次更新消息";
        }
      },
    })
  </script>
</body>

</html>